'use strict';
const db = uniCloud.database();
const diffTime = 8 * 60 * 60 * 1000;
// 获取指定的今天的时间戳
function getMsByDate(timeStr, dayStr) {
	return new Date(dayStr+' '+timeStr).getTime()-diffTime;
}
// 根据时间戳得到年月日
function getDateByMs(msTime) {
	let date = new Date(msTime+diffTime);
	return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
}
exports.main = async (event, context) => {
	return {
		startDayTime:getMsByDate('00:00:00','2020-2-9'),
		endDayTime:getMsByDate('23:59:59','2020-2-9'),
		getDayByMs:getDateByMs(Date.now()),
		nowTIme:Date.now()
	}
	return getDay(1581179141676);
	let whereMap = {
		'jobnumber': '010'
	};
	let collection = db.collection('company_collect');
	// // 查询当天是否存在数据
	const userRes = await collection.where(whereMap).get();
	return userRes;
	/**
	 * 1581120000000 dayTime
	 * 1581179141676 createTime 1581177599000
	 * 5e3ee105c4952d004e9deba8 _id
	 */
	// if (userRes.data.length > 0) {
	let res =	await collection.doc('5e3ec6f6c21439004e2c78dd').update({
			'super':1
		});
	// }
	return res
};
